<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body,
    ul {
      margin: 0;
      padding: 0;
    }

    ul {
      list-style: none;
    }

    .tab-box {
      width: 383px;
      margin: 10px;
      border: 1px solid #ccc;
      border-top: 2px solid #206F96;
    }

    .tab-head {
      height: 31px;
    }

    .tab-head-div {
      width: 95px;
      height: 30px;
      float: left;
      border-bottom: 1px solid #ccc;
      border-right: 1px solid #ccc;
      background: #206F96;
      line-height: 30px;
      text-align: center;
      cursor: pointer;
      color: #fff;
    }

    .tab-head .current {
      background: #fff;
      border-bottom: 1px solid #fff;
      color: #000;
    }

    .tab-head-r {
      border-right: 0;
    }

    .tab-body-div {
      display: none;
      margin: 20px 10px;
    }

    .tab-body .current {
      display: block;
    }
  </style>
</head>

<body>
  <div class="tab-box">
    <div class="tab-head">
      <div class="tab-head-div ">标签一</div>
      <div class="tab-head-div current">标签二</div>
      <div class="tab-head-div">标签三</div>
      <div class="tab-head-div tab-head-r">标签四</div>
    </div>
    <!--jkdjfk?-->
    <div class="tab-body">
      <div class="tab-body-div "> 内容1 </div>
      <div class="tab-body-div current">内容 2 </div>
      <div class="tab-body-div">内容 3 </div>
      <div class="tab-body-div"> 内容4 </div>
    </div>
  </div>
  <script>
    // 获取标签栏的所有标签元素对象
    var tabs = document.getElementsByClassName('tab-head-div');
    // 获取标签栏的所有内容对象
    var divs = document.getElementsByClassName('tab-body-div');
    // 查看你 标签有几个
    for (var i = 0; i < tabs.length; ++i) { // 遍历标签部分的元素对象
      tabs[i].onclick = function () { // 为标签元素对象添加点击事件
        // 查看你 内容有几个llllll
        for (var i = 0; i < divs.length; ++i) { // 遍历标签栏的内容元素对象
          //如果点击的标签下标和内容下标一致 则给他们俩都添加current属性 让其显示
          if (tabs[i] == this) { // 显示当前鼠标滑过的li元素
            divs[i].classList.add('current');
            tabs[i].classList.add('current');
          } else { // 隐藏其他li元素
            divs[i].classList.remove('current');
            tabs[i].classList.remove('current');
          }
        }
      }
    }
  </script>
</body>

</html>